const baseURL = 'https://xiangqin.needyoutd.com/api/'
const Url = 'https://xiangqin.needyoutd.com/new_xiangqin/web/'
export const myRequesy = (options) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseURL + options.url,
			method: options.method || 'GET',
			data: options.data || {},
			header: {
				Authorization: uni.getStorageSync('token')
			},
			success: (res) => {
				// let url = location.href
				// if (url.includes('pages/results/results')) {
				// 	console.log(111)
				// }else if(){}
				// if (res.code === 2001 || res.code === 2002 || res.code === 2003) {
				// 	uni.navigateTo({
				// 		url: '/pages/index/index.vue'
				// 	})
				// }
				resolve(res.data)

			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}

// 用户登录
export const myRequesyToken = (options) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseURL + options.url,
			method: options.method || 'GET',
			data: options.data || {},
			success: (res) => {
				resolve(res.data)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}


// 支付
export const myRequesyPay = (options) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: Url + options.url,
			method: options.method || 'GET',
			data: options.data || {},
			success: (res) => {
				resolve(res.data)

			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}
